import random


def play_game():
    print("欢迎来到猜数字游戏！")
    print("我已经生成了一个1到100之间的随机数字，请猜测这个数字是多少。")

    secret_number = random.randint(1, 100)
    attempts = 0
    min_range = 1
    max_range = 100

    while True:
        attempts += 1
        print(f"当前范围：{min_range} - {max_range}")

        guess = int(input("请输入您的猜测："))

        if guess < secret_number:
            print("猜小了！")
            min_range = guess + 1
        elif guess > secret_number:
            print("猜大了！")
            max_range = guess - 1
        else:
            print(f"恭喜您猜对了！答案是{secret_number}，您一共猜了{attempts}次。")
            break

    print("谢谢参与！")


play_game()
